/*+********************************************************
Filename: main.c
Description: a tutorial program to demonstrate simple task
    using software timer on openharmony liteos-m
Modification:
  2023.04.02 H.Zheng creation
*********************************************************-*/

#include "simpleHAL.h"
#include "los_task.h"
#include "los_swtmr.h"

//swtmr proc function 1
void swtmrFunction1(UINT32 vLedNum) {
  shalSetLed(vLedNum, LED_TOGGLE);
}  
void showError(void){
  shalSetLed(LED1, LED_ON);
  while(1) {
  }
}

int main(void) { 
  
  //init
  shalInitSysClock();
  shalInitLed();
  shalInitUart1();

  //init LOS
  LOS_KernelInit();  
  
   unsigned int ret;
  unsigned int swtmrID1, swtmrID2;
  //task 1: blink led0 with period = 2s
  ret = LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, \
                  &swtmrFunction1, &swtmrID1, LED0);
  if (ret != LOS_OK) {
    showError();
  }
  LOS_SwtmrStart(swtmrID1);
  
  //task 2: blink led1 with period = 5s
  ret = LOS_SwtmrCreate(250, LOS_SWTMR_MODE_PERIOD, \
                  &swtmrFunction1, &swtmrID2, LED1);
  if (ret != LOS_OK) {
    showError();
  }
  LOS_SwtmrStart(swtmrID2);

  
  //start LOS
  LOS_Start();

//should never reach here.
  while(1){
  }
  return 0;
}
















